package com.rocket.bedroom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rocket.bedroom.dao.ClassInfoDao;
import com.rocket.bedroom.pojo.ClassInfoEntity;
import com.rocket.bedroom.service.IClassInfoService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author: 周毅
 * @ClassName:
 * @Description: TODO
 * @Date: Create in 9:22 2020/5/7
 * @ModifyBy:
 */
@Service
public class ClassInfoServiceImpl extends ServiceImpl<ClassInfoDao, ClassInfoEntity> implements IClassInfoService {


    @Override
    public int getClassInfoCount(ClassInfoEntity classInfoEntity) {
        LambdaQueryWrapper<ClassInfoEntity> lambdaQuery = Wrappers.lambdaQuery();
        if (null != classInfoEntity) {
            if (!StringUtils.isEmpty(classInfoEntity.getClassName())) {
                lambdaQuery.eq(ClassInfoEntity::getClassName, classInfoEntity.getClassName());
            }
            if (null != classInfoEntity.getGradeId() && 0 != classInfoEntity.getGradeId()) {
                lambdaQuery.eq(ClassInfoEntity::getGradeId, classInfoEntity.getGradeId());
            }
        }
        return super.count(lambdaQuery);
    }

}
